package j.framework.core;

import j.util.pkgenerator.PG;
import j.util.web.WebUtils;

import java.util.Date;

/**
 * 系统日志记录
 * User: jason
 * Date: 2014/12/2 11:45
 */
public class SysLog implements java.io.Serializable{

    public static SysLog buildLog(String userId,String moduleId,String businessType,String operateType,String logContent,String userIP){
        SysLog log = new SysLog();
        log.setLogId(PG.getNext("LOG"));
        log.setOperateUserId(userId);
        log.setModuleId(moduleId);
        log.setBusinessType(businessType);
        log.setOperateType(operateType);
        log.setLogContent(logContent);
        log.setOperateTime(new Date());
        log.setUserIP(userIP);
        return log;
    }
    public static SysLog buildLog(String moduleId,String businessType,String operateType,String logContent,String userIP){
        return buildLog(null,moduleId,businessType,operateType,logContent,userIP);
    }

    private String logId;

    private String moduleId;
    private String moduleAuthId;

    private String businessType;

    private String operateType;

    private String className;

    private String methodName;

    private String paramsInfo;//参数信息

    private String returnValue;//返回值

    private String exception;

    private String logContent;

    private String batch;//日志批次，若一个操作产生多个日志时，根据此字段将多条日志绑定起来

    private Date operateTime;   //操作时间

    private String operateUserId;//操作人

    private String userIP;//操作人

    public String getLogId() {
        return logId;
    }
    public void setLogId(String logId) {
        this.logId = logId;
    }

    public String getModuleId() {
        return moduleId;
    }
    public void setModuleId(String moduleId) {
        this.moduleId = moduleId;
    }

    public String getModuleAuthId() {
        return moduleAuthId;
    }
    public void setModuleAuthId(String moduleAuthId) {
        this.moduleAuthId = moduleAuthId;
    }

    public String getBusinessType() {
        return businessType;
    }
    public void setBusinessType(String businessType) {
        this.businessType = businessType;
    }

    public String getOperateType() {
        return operateType;
    }
    public void setOperateType(String operateType) {
        this.operateType = operateType;
    }

    public String getClassName() {
        return className;
    }
    public void setClassName(String className) {
        this.className = className;
    }

    public String getMethodName() {
        return methodName;
    }
    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    public String getParamsInfo() {
        return paramsInfo;
    }
    public void setParamsInfo(String paramsInfo) {
        this.paramsInfo = paramsInfo;
    }

    public String getReturnValue() {
        return returnValue;
    }
    public void setReturnValue(String returnValue) {
        this.returnValue = returnValue;
    }

    public String getException() {
        return exception;
    }
    public void setException(String exception) {
        this.exception = exception;
    }

    public String getLogContent() {
        return logContent;
    }
    public void setLogContent(String logContent) {
        this.logContent = logContent;
    }

    public String getBatch() {
        return batch;
    }
    public void setBatch(String batch) {
        this.batch = batch;
    }

    public Date getOperateTime() {
        return operateTime;
    }
    public void setOperateTime(Date operateTime) {
        this.operateTime = operateTime;
    }

    public String getOperateUserId() {
        return operateUserId;
    }
    public void setOperateUserId(String operateUserId) {
        this.operateUserId = operateUserId;
    }

    public String getUserIP() {
        return userIP;
    }

    public void setUserIP(String userIP) {
        this.userIP = userIP;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SysLog sysLog = (SysLog) o;

        if (logId != null ? !logId.equals(sysLog.logId) : sysLog.logId != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return logId != null ? logId.hashCode() : 0;
    }
}
